Starting a new program


So you want to start writing a program? When you run Borland C++ for the first time, it will come up with a window titled "noname00.cpp". You can write you first program in this window. At any other time, it will be necessary to create a new window in which to write your program. This can be done using the speedbar:

or via the menus:

This will create a new, empty window in which you can write a program. You can try typing in the simple program that follows:

#include &ltiostream.h>int main()

{

	cout << "Hey! I wrote my first program!" << endl;

}

It should look like this on your screen:

Notice that Borland will change the colors of some of the things you type. The color coding relates to the meaning of the different words and symbols, and will make more sense to you when you know more about C++. In a moment we can try running this program, but first let's talk about Saving.

You can save a program either by pressing the speedbar save button (the next-to-leftmost) or selecting Save in from the File menu. The first time you save, the "Save File As" dialogue box will come up.

This gives you a chance to rename your program from the nonameXX.cpp it started as to something more appropriate. Using the arrows keys to move the cursor you can change the name, but remember: your new name should have only up to eight characters, followed by ".cpp". That is, "myprog1.cpp", "test.cpp", and "final.cpp" are all good names, but ".cpp", "myprogram100" are not. You actually need not add the ".cpp" extension explicitely; if you simply type same filename with fewer than nine characters, Borland will automatically add ".cpp" to the end.

Using the Directories portion of the Save As dialogue box you can also decide where to put your files. You can select directories by double-clicking on them in the sub-window where your directories are displayed next to little manilla folder icons. The directory to which you file will be saved is listed just above. There is probably no need for you to save your files anywhere but in u:\, but some people choose to create a special directory for their programs or for each program. (You can create new directories (=folders) using the File Manager application.)